home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 80 / CD Actual 80 Julio-Agosto 2003.iso / Linux / LinuxGazette / lg / issue47 / misc / pollman / run-backup < prev   
Encoding:
Text File  |  2002-08-14  |  1.7 KB  |  47 lines

  1. #!/bin/sh
  2. # full and incr backup script
  3. # created 27 Sep 99
  4. # Based on a script by Daniel O'Callaghan <danny@freebsd.org>
  5.  
  6. #Change the 5 variables below to fit your computer/backup
  7.  
  8. COMPUTER=myserver                 # name of this computer
  9. DIRECTORIES="/etc /home"                # directoris to backup
  10. BACKUPDIR=/backup/backups         # where to store the backups
  11. TIMEDIR=/backup/backups/last-full # where to store time of full backup
  12. TAR=/bin/tar              # name and locaction of tar
  13.  
  14. #You should not have to change anything below here
  15.  
  16. PATH=/usr/local/bin:/usr/bin:/bin
  17. DOW=`date +%a`              # Day of the week e.g. Mon
  18. DOM=`date +%d`              # Date of the Month e.g. 27
  19. DM=`date +%d%b`             # Date and Month e.g. 27Sep
  20.  
  21. # On the 1st of the month a permanet full backup is made
  22. # Every Sunday a full backup is made - overwriting last Sundays backup
  23. # The rest of the time an incremental backup is made. Each incremental
  24. # backup overwrites last weeks incremental backup of the same name.
  25. #
  26. # if NEWER = "", then tar backs up all files in the directories
  27. # otherwise it backs up files newer than the NEWER date. NEWER
  28. # gets it date from the file written every Sunday.
  29.  
  30.                 
  31. if [ $DOM = "01" ]; then  # monthly full backup
  32.     NEWER=""
  33.     $TAR $NEWER -z -c -f $BACKUPDIR/$COMPUTER-$DM.tgz $DIRECTORIES
  34. fi
  35.  
  36. if [ $DOW = "Sun" ]; then # weekly full backup
  37.         NEWER=""
  38.     NOW=`date +%d-%b`  
  39.     echo $NOW > $TIMEDIR/$COMPUTER-full-date #update full backup date
  40.     $TAR $NEWER -z -c -f $BACKUPDIR/$COMPUTER-$DOW.tgz $DIRECTORIES
  41.  
  42. else    #make incremental backup - overwrite last weeks
  43.     NEWER="--newer `cat $TIMEDIR/$COMPUTER-full-date`" #get date of last full backup
  44.     $TAR $NEWER -z -c -f $BACKUPDIR/$COMPUTER-$DOW.tgz $DIRECTORIES
  45. fi
  46.                    
  47.